<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/21
 * Time: 16:13
 */



require_once('../../vendor/autoload.php');

use Qiniu\Storage\UploadManager;
use Qiniu\Auth;

Logger::configure(array(
    'rootLogger' => array(
        'appenders' => array('default'),
    ),
    'appenders' => array(
        'default' => array(
            'class' => 'LoggerAppenderFile',
            'layout' => array(
                'class' => 'LoggerLayoutSimple'
            ),
            'params' => array(
                'file' => './my.log',
                'append' => true
            )
        )
    )
));
$logger = Logger::getLogger("qiniu");


var_dump($_FILES);
$inputFiledName = 'file';
if(empty($_FILES)){

}else{
    if(is_array($_FILES[$inputFiledName]['name'])){
            foreach ($_FILES[$inputFiledName] as $tempFile){

            }
    }
    //foreach ()
}


die();




$fileName =  time().rand(10000,99999).'.png';

$accessKey = 'UKGyvs5RB82CX-NMjxAl55pYCzqhCdkQCdSdIyAe';
$secretKey = 'nidX05Dodp6e-kvDUzlIH8WSl2A07Lp-5vsTZlEw';
$upManager = new UploadManager();
//$auth = new Auth($accessKey, $secretKey);
//$bucketName = 'yd_123_pb';
//$token = $auth->uploadToken($bucketName);
$token = 'UKGyvs5RB82CX-NMjxAl55pYCzqhCdkQCdSdIyAe:tJO27gsbLMCOJn_zXW62ahryg0I=:eyJzY29wZSI6InlkXzEyM19wYiIsImRlYWRsaW5lIjoxNTYxMTczNjIyfQ==';
$logger->info($token);
echo '****'.$token.'****';
//'UKGyvs5RB82CX-NMjxAl55pYCzqhCdkQCdSdIyAe:CtQx1d2mgCLDxr4ktIpAx5KSYbQ=:eyJzY29wZSI6InlkXzEyM19wYiIsImRlYWRsaW5lIjoxNTYxMTA4OTg1fQ==';
list($ret, $error) = $upManager->put($token, $fileName, $_FILES['file']['tmp_name']);

echo 'ret :<br>';
var_dump($ret);
echo 'error :<br>';
var_dump($error);